package com.jml.t1;

import kafka.producer.Partitioner;
import kafka.utils.VerifiableProperties;
import org.apache.kafka.common.Cluster;

import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

public class RoundRobinPartitioner implements Partitioner {

    private static AtomicLong next = new AtomicLong();

    public RoundRobinPartitioner(VerifiableProperties verifiableProperties) {
    }

    @Override
    public int partition(Object key, int numPartiotion) {
        long nextIndex = next.incrementAndGet();
        return (int) nextIndex % numPartiotion;
    }
}

